<template>
	<view class="">
		<view class="bj"></view>
		<!-- 标签切换 -->
		<view class="tabs">
			<u-tabs :list="tblist" bar-width="111" :is-scroll="false" :current="current" @change="change"
				inactive-color="#333333" active-color="#ff7200">
			</u-tabs>
		</view>
		<view class="box" v-for="(item,index) in list" :key="index">
			<view class="ordrnum">
				<view class="dingd">
					订单号：{{item.order_num}}
				</view>
				<view class="ds dsh">
					{{item.create_time}}
				</view>
			</view>
			<Modkeprodct :arr="item.mallorder"></Modkeprodct>
			<view class="hr"></view>
			<view class="btnbox" @click="checkshouhou(item.id)" v-if="item.guoqi==0">
				{{current==0?'申请售后':'查看记录'}}
			</view>
			<view class="btnboxs" v-if="item.guoqi==1">
				<view class="leftbox">
					<image src="../../static/image/homepage.png" mode=""></image>
					<text>该商品已超过售后期</text>
				</view>
				<view class="rightbox">
					申请退货
				</view>
			</view>
			<view class="hrs"></view>
		</view>
		<view class="kongbox">
			<u-empty text="暂无数据" mode="list" v-if="list.length==0" margin-top="50rpx"></u-empty>
		</view>
	</view>
</template>

<script>
	import Modkeprodct from "../../components/Modkeprodct/index.vue"
	import {
		getsalelist
	} from "../../api/api/index.js"
	export default {
		data() {
			return {
				tblist: [{
					name: "售后申请"
				}, {
					name: "申请记录"
				}],
				current: 0,
				flag: false,
				limit: 20,
				page: 0,
				list: [],
				type: 0
			}
		},
		methods: {
			change(index) {
				this.current = index;
				this.type = index
				this.page = 0
				this.flag = false
				this.list = []
				this.public()
			},
			// 申请售后
			checkshouhou(v) {
				if (this.current == 0) {
					this.jumpLink({
						link: "/pages/sqafter_sale/index",query:{id:v}
					})
				} else {
					this.jumpLink({
						link: "/pages/exchangexq/index",query:{id:v}
					})
				}
			},
			public(flag) {
				if (this.flag) {
					return uni.showToast({
						title:"没有更多了",
						icon:"none",
						duration:1000
					})
				}
				this.page++
				uni.showLoading({
					title: "加载中"
				})
				let data = {
					page: this.page,
					limit: this.limit,
					type: this.type
				}
				getsalelist(data).then(res => {
					uni.hideLoading()
					this.list = this.list.concat(res.data)
					if (res.data.length < this.limit) {
						this.flag = true
					}
				})
			}
		},
		components: {
			Modkeprodct
		},
		onShow() {
			this.page = 0
			this.flag = 0
			this.list = []
			this.public()
		},
		onReachBottom() {
			this.public()
		}
	}
</script>

<style scoped lang="scss">
	.bj {
		background-color: #F42121;
		height: 124rpx;
		width: 100%;
	}

	.tabs {
		position: absolute;
		left: 25rpx;
		top: 52rpx;
		width: 700rpx;
		border-radius: 100rpx;
	}

	.box {
		width: 700rpx;
		background-color: #FFFFFF;
		margin-left: 25rpx;

		.ordrnum {
			display: flex;
			justify-content: space-between;
			margin-left: 20rpx;
			padding-top: 42rpx;
			padding-bottom: 20rpx;
			font-size: 22rpx;
			box-sizing: border-box;

			.dingd {
				color: #666666;
			}

			.dsh {
				color: #999999;
			}

			.ds {
				margin-right: 31rpx;
			}
		}

		.hr {
			width: 678rpx;
			margin-left: 10rpx;
			height: 1rpx;
			background-color: #000000;
			opacity: 0.2;
			margin-top: 15rpx;
		}

		.hrs {
			width: 100%;
			height: 21rpx;
			background-color: #DDDDDD;
		}

		.btnbox {
			width: 186rpx;
			height: 58rpx;
			background-color: #ff8400;
			border-radius: 29rpx;
			text-align: center;
			font-family: MicrosoftYaHei;
			font-size: 24rpx;
			line-height: 58rpx;
			color: #ffffff;
			margin-top: 20rpx;
			margin-bottom: 20rpx;
			margin-left: 490rpx;
		}

		.btnboxs {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.leftbox {
				display: flex;
				align-items: center;

				image {
					width: 25rpx;
					height: 25rpx;
					margin-left: 5rpx;
				}

				text {
					font-family: MicrosoftYaHei;
					font-size: 24rpx;
					color: #666666;
					margin-left: 8rpx;
				}
			}

			.rightbox {
				width: 186rpx;
				height: 58rpx;
				background-color: #f1f1f1;
				border-radius: 29rpx;
				border: solid 2rpx #cccccc;
				line-height: 58rpx;
				text-align: center;
				font-family: MicrosoftYaHei;
				font-size: 24rpx;
				color: #9d9c9c;
				margin-right: 28rpx;
				margin-bottom: 20rpx;
				margin-top: 20rpx;
			}
		}
	}
	.kongbox{
		padding-top: 80rpx;
		box-sizing: border-box;
	}
</style>
